package ru.teachme.servlets;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet(name = "AuthorisationServlet", urlPatterns = {"/authorisation"})
public class AuthorisationServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter pw = response.getWriter();
        String action = request.getParameter("action");
        String userName = request.getParameter("username");
        String password = request.getParameter("password");
        if ("signin".equals(action)) {
            pw.println("success <br>");
            pw.println("User: " + userName + "<br>");
            pw.println("Password: " + password + "<br>");
        } else {
            pw.println("fail");
        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
